import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { codeInspectorPlugin } from 'code-inspector-plugin'


// https://vitejs.dev/config/
export default defineConfig(() => {

  return {
    plugins: [
      vue(),
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
      codeInspectorPlugin({
        bundler: 'vite'
      })
    ],
    // modules: {
    //   rules: [
    //     {
    //       test: /\.bpmnlintrc$/,
    //       use: [{ loader: 'bpmnlint-loader' }]
    //     }
    //   ]
    // },
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
        '~': fileURLToPath(new URL('./', import.meta.url)),
      },

    },
    server: {
      cors: true,
      open: true,
      host: '127.0.0.1',
      port: 5173,
      proxy: {
        '/api': {
          target: 'http://127.0.0.1:8080/',
          changeOrigin: true,
          logLevel: 'debug',
          secure: false,
          rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
    },
  }
})

